import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.CommonDataSource;
import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * @auther 尚智江
 * @Date 2022/5/14 0:02
 */
public class Exam02 {
    public static DataSource dataSource = null;
    static {
        ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
        try {
            comboPooledDataSource.setDriverClass("com.mysql.cj.jdbc.Driver");
            comboPooledDataSource.setJdbcUrl("jdbc:mysql://localhost:3306/jdbc?serverTimezone=GMT%2B8");
            comboPooledDataSource.setUser("root");
            comboPooledDataSource.setPassword("1234");
            comboPooledDataSource.setInitialPoolSize(5);
            comboPooledDataSource.setMaxPoolSize(5);
            dataSource = comboPooledDataSource;
        }catch (Exception exception){
            exception.printStackTrace();
        }
    }

    public static void main(String[] args) throws SQLException {
        System.out.println(dataSource.getConnection());
    }
}
